package com.quanxiaoha.weblog.web.controller.record;

import com.quanxiaoha.weblog.common.entity.ScheduleSkillModel;
import com.quanxiaoha.weblog.common.service.IScheduleSkillModelService;
import com.quanxiaoha.weblog.common.utils.Response;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Roy
 * @since 2025-06-13
 */
@Slf4j
@RestController
@RequestMapping("/todo")
@Api(tags = "技能模型管理")
public class ScheduleSkillModelController {

    @Autowired
    private IScheduleSkillModelService scheduleSkillModelService;

    @PostMapping("/model")
    @ApiOperation("创建技能模型")
    public Response<Boolean> createSkillModel(@RequestBody ScheduleSkillModel scheduleSkillModel) {
        log.info("创建技能模型，参数：{}", scheduleSkillModel);
        boolean result = scheduleSkillModelService.createScheduleSkillModel(scheduleSkillModel);
        return Response.success(result);
    }

    @DeleteMapping("/model/{id}")
    @ApiOperation("删除技能模型")
    public Response<Boolean> deleteSkillModel(@PathVariable Long id) {
        log.info("删除技能模型，ID：{}", id);
        boolean result = scheduleSkillModelService.deleteScheduleSkillModelById(id);
        return Response.success(result);
    }

    @PutMapping("/model")
    @ApiOperation("更新技能模型")
    public Response<Boolean> updateSkillModel(@RequestBody ScheduleSkillModel scheduleSkillModel) {
        log.info("更新技能模型，参数：{}", scheduleSkillModel);
        boolean result = scheduleSkillModelService.updateScheduleSkillModel(scheduleSkillModel);
        return Response.success(result);
    }

    @GetMapping("/model/{id}")
    @ApiOperation("获取技能模型详情")
    public Response<ScheduleSkillModel> getSkillModel(@PathVariable Long id) {
        log.info("获取技能模型详情，ID：{}", id);
        ScheduleSkillModel skillModel = scheduleSkillModelService.getScheduleSkillModelById(id);
        return Response.success(skillModel);
    }

    @GetMapping("/model/page")
    @ApiOperation("分页查询技能模型列表")
    public Response<IPage<ScheduleSkillModel>> pageSkillModel(
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "10") Integer size,
            ScheduleSkillModel scheduleSkillModel) {
        log.info("分页查询技能模型列表，当前页：{}，每页条数：{}，查询条件：{}", current, size, scheduleSkillModel);
        Page<ScheduleSkillModel> page = new Page<>(current, size);
        IPage<ScheduleSkillModel> result = scheduleSkillModelService.pageScheduleSkillModel(page, scheduleSkillModel);
        return Response.success(result);
    }
}
